using System;
using System.Collections.Generic;
using System.Text;

namespace uk.co.tonyditchfield.tort.persistence
{
    public interface IDBTransactionScope : IDisposable
    {
        /// <summary>
        /// Persists Object to database
        /// </summary>
        /// <param name="o">The object to persist</param>
        /// <returns>The same object with additional identity (where appropriate)</returns>
        /// <exception cref="PersistenceException"></exception>
        object Save(object o);

        /// <summary>
        /// Persists Objects to database
        /// </summary>
        /// <param name="o">The object to persist</param>
        /// <param name="identity">the objects database identity</param>
        /// <returns>rows affected</returns>
        int Save(object o, out object identity);

        object Update(object o);
        int Update(ICollection<object> oCollection);

        object Delete(object o);
        int Delete(ICollection<object> oCollection);

        object LoadByPK(Type objectToRetrieve, object primeKey);
        object LoadByQuery(string query);
        ICollection<object> LoadCollection(string query);

        void Rollback();
        void Complete();
    }
}
